using System.Data;
using System.Linq;

namespace Magiq.Databases.Delete
{
    public class DeleteCommandBuilder : CommandBuilder
    {
        public DeleteCommandBuilder(IOrmAdapter ormAdapter, IQueryable where)
            : base(ormAdapter, where, true)
        {
            SetCommand(ormAdapter.GetSelectCommand(where));
        }

        public override IDbCommand GetCommand()
        {
            Command.CommandText = OrmAdapter.Dialect.DeleteClauseFor(BaseTableName, From);
            return Command;
        }
    }
}